home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 10
/
FM Towns Free Software Collection 10.iso
/
ms_dos
/
tool
/
txf
/
src
/
txfswchk.c
< prev
Wrap
C/C++ Source or Header
|
1994-09-17
|
6KB
|
319 lines
/*====================================================================
*
* TXF switch checker module
*
*====================================================================
* copyright(C) 1992-1994 T.Nakatani
*====================================================================
*/
#include "txf.h"
char *tkl, *tkf, *tkq;
void case_k(char c, char far *str)
{
if (c == 'f') {
if (kf != NULL) {
free(kf);
}
kf = ktrans(str);
}
if (c == 'l') {
if (kl != NULL) {
free(kl);
}
kl=ktrans(str);
}
if (c =='q') {
if (kq != NULL) {
free(kq);
}
kq = ktrans(str);
}
tkl = kl;
tkf = kf;
tkq = kq;
#ifdef DEBUG
if (viewmode > 5) {
fprintf(stderr, "SWITH=k%c\n", c);
fprintf(stderr, "ぶら下げ文字=%s(%Np)\n", kl,kl);
fprintf(stderr, "送り出し文字=%s(%Np)\n", kf,kf);
fprintf(stderr, "引用通知文字=%s(%Np)\n", kq,kq);
}
#endif
}
void case_r(char c)
{
if (c == NUL) {
retflg = 1;
}
else if (c == 'z') {
removeeofflg = 1;
}
else if (c =='b') {
removebakfile = 1;
}
}
void case_e(char c)
{
if ((c == 'x') && (*wcfile == NUL)) {
if (exflg) exchangedriver();
exflg = 0;
}
#if 0
else if (c == 'p') useoldex = 0;
else if (c == 's') useoldex = 1;
#endif
}
int chkoprnd(char next)
{
if (next == '-') return (0);
if (next == '@') return (0);
if (next == NUL) return (0);
return (1);
}
char *nrcpy(char far *fstr)
{
static char nstr[80];
far_strcpy(nstr, fstr);
return (nstr);
}
void swlow(int *i, char far **val)
{
switch(val[*i][1]) {
case 'i':
if (val[*i][2] == NUL) {
if (chkoprnd(val[*i+1][0])) {
far_strcpy(inputfile, val[*i+1]);
}
else {
(*i)--;
}
}
if (val[*i][2] == 'o') {
far_strcpy(wcfile, val[*i+1]);
}
if (val[*i][2] == 's') {
ishflg = 1;
(*i)--;
}
break;
case 'c':
if (chkoprnd(val[*i+1][0])) {
cent = atoi(nrcpy(val[*i+1]));
}
else {
cent = 60;
(*i)--;
}
break;
case 'l':
if (far_strlen(val[*i]) == 2) {
if (chkoprnd(val[*i+1][0])) {
maxc = atoi(nrcpy(val[*i+1]));
}
else {
(*i)--;
}
}
break;
case 'b':
if (chkoprnd(val[*i+1][0])) {
base = atoi(nrcpy(val[*i+1]));
}
else {
base = 0;
(*i)--;
}
break;
case 'k':
case_k(val[*i][2], val[*i+1]);
break;
case 'f':
format = 1;
if (chkoprnd(val[*i+1][0])) {
starttxf = atol(nrcpy(val[*i+1]));
}
else {
(*i)--;
}
if (chkoprnd(val[*i+2][0])) {
endtxf = atol(nrcpy(val[*i+2]));
(*i)++;
}
if ((val[*i][2] == 'x') && (*wcfile == NUL)) {
if (base == 0) setleft0(); /* 自動検索 */
if (base > 0) setleft();
txform();
format = 0;
}
break;
case 'a':
if (command_option) {
read_def_flg = 0;
}
else {
init_allswitch();
}
(*i)--;
break;
case 'd':
if (val[*i][2] == NUL) {
if (chkoprnd(val[*i+1][0])) {
far_strncpy(tfile[0], val[*i+1], 64);
mktfilename();
}
else{
(*i)--;
}
}
break;
case 'e':
if (val[*i][2] == NUL) {
if (exflg > EX_MAX) errexit("too many exchange block");
exold[exflg] = &val[*i+1][0];
if (chkoprnd(val[*i+2][0])) {
exnew[exflg] = val[*i+2];
(*i)++;
}
exflg += 1;
}
else {
case_e(val[*i][2]);
(*i)--;
}
break;
case '?':
case 'h':
credit(basedir);
default:
fprintf(stderr, "Error:invailed parameter'%s'\n", val[*i]);
credit(basedir);
/* exit(1); */
}
}
void swhigh(int *i, char far **val)
{
switch(val[*i][1]) {
case 'o':
if (chkoprnd(val[*i+1][0])) {
far_strcpy(outputfile, val[*i+1]);
}
else {
(*i)--;
}
break;
case 'm':
if ((val[*i][2] == 'r') && chkoprnd(val[*i+1][0])) {
right = atoi(nrcpy(val[*i+1]));
}
else if ((val[*i][2] == 'l') && chkoprnd(val[*i+1][0])) {
left = atoi(nrcpy(val[*i+1]));
}
else {
(*i)--;
}
break;
case 's':
sep = val[*i+1][0];
break;
case 't':
if (chkoprnd(val[*i+1][0])) {
tabsize = atoi(nrcpy(val[*i+1]));
}
else {
(*i)--;
}
break;
case 'v':
viewmode = 1;
if (val[*i][2] != NUL) {
viewmode = atoi(nrcpy(&val[*i][2]));
(*i)--;
}
else {
if (chkoprnd(val[*i+1][0])) {
viewmode = atoi(nrcpy(val[*i+1]));
}
else {
(*i)--;
}
}
break;
case 'r':
case_r(val[*i][2]);
(*i)--;
break;
case 'n':
if (val[*i][2] == NUL) {
format = 0;
(*i)--;
}
break;
case 'x':
tabx = 1;
(*i)--;
break;
case 'q':
quoteflg = 1;
(*i)--;
break;
case 'p':
setline = 2;
(*i)--;
break;
default:
fprintf(stderr, "Error:invailed parameter'%Fs'\n", val[*i]);
credit(basedir);
/* exit(1); */
}
}
void swchk(int count, char far **val)
{
int i;
char *env;
if ((env = getenv("TXF")) != NULL) {
if (strcmp(env,"TEST") == 0) {
for (i = 0; i < count; i++) {
fprintf(stderr, "Info:PARA[%d]=<%s>\n", i, nrcpy(*(val+i)));
}
fprintf(stderr, "Info:max=%d\n", count);
}
}
for (i = 0; val[i] != NULL; i++) {
if (val[i][0] == '-') {
val[i][1] = tolower(val[i][1]);
val[i][2] = tolower(val[i][2]);
#ifdef DEBUG
if (viewmode > 2) {
fprintf(stderr, "Info:PARA=<%s>\n", nrcpy(&(val[i][0])));
}
#endif
if (val[i][1] <= 'l') {
swlow(&i, val);
}
else {
swhigh(&i, val);
}
i++;
}
else if (val[i][0] == '@') {
read_commandfile(nrcpy(&val[i][1]), 1);
}
else if (*inputfile == NUL) {
far_strcpy(inputfile, val[i]);
}
}
kl=tkl;
kf=tkf;
kq=tkq;
}